﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using com.vs.DataAccess;
using com.vs.DataAccess.DO;
using com.vs.General;
using com.vs.General.RF;

namespace com.vs.RF.Web.receiving
{
    public partial class ItemEntryHandling : RFHandlingPage
    {
        private int iIntRecNum = 0;
        protected DataTable dtRcpDtl = null;
        private string stItem = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            stSourcePage = "receiving/ItemEntry.aspx";
            stTargetPage = "receiving/CheckInQtyEntry.aspx";

            go();
        }

        protected override void parseRequest()
        {
            stItem = Request["tbItem"];
            if (StringManager.IsEmpty(stItem))
                stError = MessageManager.MSG_RCP_027;//货品必须输入
        }

        protected override void procData()
        {
            DataRow[] arRows = null;
            try
            {
                dtRcpDtl = ReceiptDetailDO.GetTableByColumn(rfSess, "INTERNAL_RECEIPT_NUM", (int)Session[RFSupport.INTERNAL_RECEIPT_NUM]);
                arRows = dtRcpDtl.Select("ITEM = '" + this.stItem + "'");
                if (arRows == null || arRows.Length < 1)
                    stError = MessageManager.MSG_RCP_028; //"可收货列表中不存在该货品";
                else
                {
                    Session["INTERNAL_RECEIPT_LINE_NUM"] = DataManager.GetInt(arRows[0], "INTERNAL_RECEIPT_LINE_NUM");
                    ItemDO itmDO = ItemDO.GetModelByPK(rfSess, stItem, DataManager.GetString(arRows[0], "COMPANY"));
                    Session["ITEM_DO"] = itmDO;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.LogException(rfSess, ex);
                stError = ex.Message;
            }
        }

    }
}
